	$('form').bootstrapValidator({
      // 默认的提示消息
      message: 'This value is not valid',
      // 表单框里右侧的icon
      feedbackIcons: {
		valid: 'glyphicon glyphicon-ok',
		invalid: 'glyphicon glyphicon-remove',
		validating: 'glyphicon glyphicon-refresh'
      },
      submitHandler: function (validator, form, submitButton) {
      	//0.45支持，0.5以上好像不支持
        // 表单提交成功时会调用此方法
        // validator: 表单验证实例对象
        // form  jq对象  指定表单对象
        // submitButton  jq对象  指定提交按钮的对象
        alert('aaa');
      },
      fields: {
		"username":{
			message: '用户名验证失败',
			validators: {
				notEmpty: {
              		message: '用户名不能为空'
            	},
            	stringLength: {
            		min: 2,
                    max: 5,
                    message: '姓字长度2-5位,'
              	},
	            regexp: { //正则表达式
	              regexp: /[\u4e00-\u9fa5]/,
	              message: '姓名只能用汉字'
	            }
			}
      	},
      	"clazz": {
      		validators:{
      			callback: {
		            message: '必须选择一个有效班级',
		            //返回true/false
		            callback: function (value, validator) {
		                if(value == "00b"){
		                    return false;
		                }else{
		                    return true;
		                }
		            }
		    	}
      		}
      	},
      	"cardid": {
      		message: '身份证号码验证失败',
      		validators:{
      			notEmpty: {
              		message: '身份证号码不能为空'
            	},
            	/*regexp: {
            		regexp: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
            		message: "身份证号码不正确"
            	},*/
            	callback: {
            		message: "身份证号码输入有误,请核对!",
            		callback :function (val, validator, $field){
            			var p = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
					    var factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
					    var parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
					    var code = val.substring(17);
					    if(p.test(val)) {
					        var sum = 0;
					        for(var i=0;i<17;i++) {
					            sum += val[i]*factor[i];
					        }
					        if(parity[sum % 11] == code.toUpperCase()) {
					            return true;
					        }
					    }
					    return false;
            		}
            	}
      		}
      	},
      	cardid1: {
		    validators: {
		        identical: {
		            field: 'cardid',
		            message: '两次输入的身份证号码不相符'
		        }
		    }
		},
		"addr": {
			validators: {
      			notEmpty: {
              		message: '地址不能为空'
            	}
            }
		},
		"mobile": {
			validators: {
                notEmpty: {
                    message: '手机号不能为空'
                },
                regexp: {
                    regexp: /^1\d{10}(,1\d{10})*/,
                    message: '手机号格式错误'
                }
            }
		},
		"card-p": {
            validators: {
                notEmpty: {
                    message: '上传图片不能为空'
                },
                file: {
                    extension: 'png,jpg,jpeg,jpe',
                    type: 'image/png,image/jpg,image/jpeg',
                    message: '不是有效的文件格式,请重新选择图片(png,jpg)'
                }
            }
        },
        "card-p1": {
            validators: {
                notEmpty: {
                    message: '上传图片不能为空'
                },
                file: {
                    extension: 'png,jpg,jpeg,jpe',
                    type: 'image/png,image/jpg,image/jpeg',
                    message: '不是有效的文件格式,请重新选择图片(png,jpg)'
                }
            }
        },
        "huname": {
			message: '家长姓名验证失败',
			validators: {
				notEmpty: {
              		message: '家长姓名不能为空'
            	},
            	stringLength: {
            		min: 2,
                    max: 5,
                    message: '家长姓字长度2-5位,'
              	},
	            regexp: { //正则表达式
	              regexp: /[\u4e00-\u9fa5]/,
	              message: '家长姓名只能用汉字'
	            }
			}
      	},
      	"huname1": {
			message: '称呼验证失败',
			validators: {
				notEmpty: {
              		message: '称呼不能为空'
            	},
            	stringLength: {
            		min: 1,
                    max: 10,
                    message: '称呼长度1-10位,'
              	},
	            regexp: { //正则表达式
	              regexp: /[\u4e00-\u9fa5]/,
	              message: '称呼只能用汉字'
	            }
			}
      	},
      	"hmobile": {
			validators: {
                notEmpty: {
                    message: '家长手机号不能为空'
                },
                regexp: {
                    regexp: /^1\d{10}(,1\d{10})*/,
                    message: '家长手机号格式错误'
                }
            }
		},
		"huname_1": {
			message: '家长姓名验证失败',
			validators: {
            	stringLength: {
            		min: 2,
                    max: 5,
                    message: '家长姓字长度2-5位,'
              	},
	            regexp: { //正则表达式
	              regexp: /[\u4e00-\u9fa5]/,
	              message: '家长姓名只能用汉字'
	            }
			}
      	},
      	"huname1_1": {
			message: '称呼验证失败',
			validators: {
            	stringLength: {
            		min: 1,
                    max: 10,
                    message: '称呼长度1-10位,'
              	},
	            regexp: { //正则表达式
	              regexp: /[\u4e00-\u9fa5]/,
	              message: '称呼只能用汉字'
	            }
			}
      	},
      	"hmobile_1": {
			validators: {
                regexp: {
                    regexp: /^1\d{10}(,1\d{10})*/,
                    message: '家长手机号格式错误'
                }
            }
		},
        "checked":{
        	validators: {
        		notEmpty: {
        			message: '必须选中才能提交'
        		}
        	}
        }
     }
    }).on("success.form.bv",function(e){
		// 版本号0.4.5支持
		// 版本号v0.5.2-dev支持
		//alert('aaa');
		e.preventDefault();
		var formData = new FormData($("#form1")[0]);
		$.ajax({
            type: 'post',
            url: 'update.php',
            data: formData,//$('#form1').serialize(),
            dataType: 'json',
            contentType: false, //上传文件必须
			processData: false, //上传文件必须
            success: function (result) {
            	//console.log(result);
                if (result.success == "1") {
                	alert("提交成功,确认后返回首页!");
                    console.log(result.data);
                   	location.href = 'index.php';
                } else {
                    console.log('提交失败，详情：'+ result.data);
                }
            },
            error: function (e) {
                alert("提交出错");
                console.log(e);
            }
        })
		
		
		
		
	}).on('error.form.bv', function (e) { //点击提交验证失败之后
        //$('[type="submit"]').removeAttr("disabled");
    });